#include "Camera.h"
#include <math.h>
#include <d3d9.h>
#include <d3dx9.h>

//Defaults
Camera::Camera(){
	
	EyePoint.x = 0;
	EyePoint.y = 0;
	EyePoint.z = -2;

	LookAt.x = 0;
	LookAt.y = 0;
	LookAt.z = 0;

	UpVector.x = 0.0f;
	UpVector.y = 1.0f;
	UpVector.z = 0.0f;
	
	rotation = 0.0f;
	
	fov = D3DXToRadian(60.0f);
	aspectRatio = 640/480;
	nearPlane = 1.0f;
	farPlane = 100.0f;
}

//Getters and setters


float Camera::GetRot(){
	return rotation;
}

void Camera::SetRot(float pr){
	rotation = pr;
}

	D3DXMATRIX* Camera::GetViewMatrix(){
		D3DXMatrixLookAtLH(&ViewMatrix, &EyePoint, &LookAt, &UpVector); 
		return &ViewMatrix;
	}

	D3DXMATRIX* Camera::GetProjectionMatrix(){
		D3DXMatrixPerspectiveFovLH(&matProjection,
							   fov,    // the horizontal field of view
							   aspectRatio, // aspect ratio
							   nearPlane,    // the near view-plane
							   farPlane);    // the far view-plane
		return &matProjection;
	}


	D3DXVECTOR3* Camera::GetEyePos(){
		return &EyePoint;
	}
	D3DXVECTOR3* Camera::GetLookAt()	{
		return &LookAt;
	}
	D3DXVECTOR3* Camera::GetUpVector(){
		return &UpVector;
	}
	
	void Camera::SetLookAt(D3DXVECTOR3 plook){
		LookAt = plook;
	}
	
	void Camera::SetUpVector(D3DXVECTOR3 pUp){
		UpVector = pUp;
	}

	void Camera::SetEyePos(D3DXVECTOR3 pEye){
		 EyePoint = pEye;
	}

float Camera::GetFov(){
	return fov;
}
float Camera::GetAspectRatio(){
	return aspectRatio;
}
float Camera::GetNearPlane(){
	return nearPlane;
}

float Camera::GetFarPlane(){
	return farPlane;
}

//Setters
void Camera::SetFov(float pFov){
	fov = pFov;
}
void Camera::SetAspectRatio(float pAR){
	aspectRatio = pAR;
}

void Camera::SetNearPlane(float pNP){
	nearPlane = pNP;
}

void Camera::SetFarPlane(float pFP){
	farPlane = pFP;
}
